package com.liberty.ribbon.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.Date;

@RestController
@RequestMapping("ribbon")
public class RibbonController {

    @Autowired
    private RestTemplate restTemplate;

    @Value("${service-url.liberty-server}")
    private String serviceUrl;

    @GetMapping("/")
    public String hello(@RequestParam String name) {

        String url = serviceUrl + "/server/hello?name=" + name;

        return restTemplate.getForObject(url, String.class);
    }
}
